package cn.net.msg.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import cn.net.msg.dao.FindDao;
import cn.net.msg.model.TbFavourite;
import cn.net.msg.model.TbMood;
import cn.net.msg.service.base.DaoSupport;
import cn.net.msg.service.base.Order;

@Component("findDao")
public class FindDaoImpl extends DaoSupport implements FindDao {

    @Override
    public List<TbMood> getPopMoodForList(int firstIndex, int maxResult,
            Order order, String propertyName) {
        // TODO Auto-generated method stub
        return super.paging(TbMood.class, firstIndex, maxResult, null, order, propertyName);
    }

    @Override
    public List<TbFavourite> getPopFavouriteForList(int firstIndex, int maxResult) {
        // TODO Auto-generated method stub
        String sql = "select t.* from tb_favouritelist t group by t.Favouritelist_title " +
        "order by (" +
        "select count(*) from tb_favouritelist a where a.Favouritelist_title = t.Favouritelist_title) " +
        "desc";
        List<TbFavourite> list = (List<TbFavourite>)super.executeGetPopFavouriteListNativeQuery(sql, firstIndex, maxResult);
        return list;
    }

}
